package com.myzhouye.biz.bean;/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @program: maple-main
 * @description: 统一返回
 * @author: 那条蠢鱼
 * @create: 2023-01-09 15:12
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> implements Serializable {
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1L;


    /**
     * 业务错误码
     */
    private long code;
    /**
     * 结果集
     */
    private T data;
    /**
     * 描述
     */
    private String msg;


    public boolean ok(){
        return code==0;
    }


    public static <T> R<T> ok(T data) {
        return new R<T>(0, data, "成功");
    }
    public static <T> R<T> success() {
        return R.ok(null);
    }

    public static <T> R<T> failed(String msg) {
        return new R<>(1,null,msg);
    }


}
